﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace Terraria.Localization
{
	// Token: 0x0200031D RID: 797
	public class GameCulture
	{
		// Token: 0x17000212 RID: 530
		// (get) Token: 0x06001DEE RID: 7662 RVA: 0x00015391 File Offset: 0x00013591
		public bool IsActive
		{
			get
			{
				return Language.ActiveCulture == this;
			}
		}

		// Token: 0x17000213 RID: 531
		// (get) Token: 0x06001DEF RID: 7663 RVA: 0x0001539B File Offset: 0x0001359B
		public string Name
		{
			get
			{
				return this.CultureInfo.Name;
			}
		}

		// Token: 0x06001DF0 RID: 7664 RVA: 0x000153A8 File Offset: 0x000135A8
		public static GameCulture FromLegacyId(int id)
		{
			if (id < 1)
			{
				id = 1;
			}
			return GameCulture._legacyCultures[id];
		}

		// Token: 0x06001DF1 RID: 7665 RVA: 0x00440CA8 File Offset: 0x0043EEA8
		public static GameCulture FromName(string name)
		{
			return GameCulture._legacyCultures.Values.SingleOrDefault((GameCulture culture) => culture.Name == name) ?? GameCulture.English;
		}

		// Token: 0x06001DF2 RID: 7666 RVA: 0x000153BC File Offset: 0x000135BC
		public GameCulture(string name, int legacyId)
		{
			this.CultureInfo = new CultureInfo(name);
			this.LegacyId = legacyId;
			GameCulture.RegisterLegacyCulture(this, legacyId);
		}

		// Token: 0x06001DF3 RID: 7667 RVA: 0x000153DE File Offset: 0x000135DE
		private static void RegisterLegacyCulture(GameCulture culture, int legacyId)
		{
			if (GameCulture._legacyCultures == null)
			{
				GameCulture._legacyCultures = new Dictionary<int, GameCulture>();
			}
			GameCulture._legacyCultures.Add(legacyId, culture);
		}

		// Token: 0x04001935 RID: 6453
		public static readonly GameCulture English = new GameCulture("en-US", 1);

		// Token: 0x04001936 RID: 6454
		public static readonly GameCulture German = new GameCulture("de-DE", 2);

		// Token: 0x04001937 RID: 6455
		public static readonly GameCulture Italian = new GameCulture("it-IT", 3);

		// Token: 0x04001938 RID: 6456
		public static readonly GameCulture French = new GameCulture("fr-FR", 4);

		// Token: 0x04001939 RID: 6457
		public static readonly GameCulture Spanish = new GameCulture("es-ES", 5);

		// Token: 0x0400193A RID: 6458
		public static readonly GameCulture Russian = new GameCulture("ru-RU", 6);

		// Token: 0x0400193B RID: 6459
		public static readonly GameCulture Chinese = new GameCulture("zh-Hans", 7);

		// Token: 0x0400193C RID: 6460
		public static readonly GameCulture Portuguese = new GameCulture("pt-BR", 8);

		// Token: 0x0400193D RID: 6461
		public static readonly GameCulture Polish = new GameCulture("pl-PL", 9);

		// Token: 0x0400193E RID: 6462
		private static Dictionary<int, GameCulture> _legacyCultures;

		// Token: 0x0400193F RID: 6463
		public readonly CultureInfo CultureInfo;

		// Token: 0x04001940 RID: 6464
		public readonly int LegacyId;
	}
}
